#ifndef SOURCETRACERAY_ENGINETRACE_HPP
#define SOURCETRACERAY_ENGINETRACE_HPP
#include "Trace.hpp"
#include "TraceFilter.hpp"

struct Ray_t {

    VectorAligned  m_Start;	// 起点，以范围为中心
    VectorAligned  m_Delta;	// 方向+射线长度
    VectorAligned  m_StartOffset;	// 将此添加到 m_Start 以获得实际的光线开始
    VectorAligned  m_Extents;	// 描述沿射线拉伸的轴对齐框
    const void* m_pWorldAxisTransform = nullptr; // 世界轴变换
    bool	m_IsRay = true;	// 范围是否为0
    bool	m_IsSwept = false;	// delta是否为0

    void Init(Vector const& start, Vector const& end)
    {

        // 结束向量减起始向量
        m_Delta = end - start;

        // delta是否为0
        m_IsSwept = (m_Delta.LengthSqr() != 0);

        m_Extents.x = m_Extents.y = m_Extents.z = 0.0f;
        m_pWorldAxisTransform = nullptr;
        m_IsRay = true;

        // 将 m_Start 偏移到框的中心...
        m_StartOffset.x = m_StartOffset.y = m_StartOffset.z = 0.0f;
        m_Start = start;
    }
};

class IEngineTrace {
public:
    // 填充虚表
    virtual void    Constructor() = 0;
    virtual int     GetPointContents() = 0;
    virtual int     GetPointContents_Collideable() = 0;
    virtual void    ClipRayToEntity() = 0;
    virtual void    ClipRayToCollideable() = 0;

    // TraceRay
    virtual void    TraceRay(const Ray_t &ray, unsigned int fMask, ITraceFilter *pTraceFilter, trace_t *pTrace) = 0;
};

#endif //SOURCETRACERAY_ENGINETRACE_HPP
